/*
 *  Copyright 2001-2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package ar.uba.fi.posgrado.economy.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import ar.uba.fi.posgrado.common.model.AbstractDomainObject;
import ar.uba.fi.posgrado.common.model.User;

/**
 * Clase que se usa para encapsular los Egresos.<br><br>
 * 
 * Un egreso registra el pago de un honorario.<br>
 * No se permiten pagos parciales, de manera q siempre un Egreso va a estar
 * relacionado con uno y solo un Honorario.<br>
 * 
 * @author nicolas.gonzalez
 * @see AbstractDomainObject
 */
@Entity
@Table(name = "EGRESO")
@SuppressWarnings("serial")
public class Pay extends AbstractDomainObject {

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "NOMBRE_USUARIO")
    private User user;
    
    @Column(name = "FECHA")
    private Date date;
    
    @Column(name = "VALOR")
    private Double value;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ID_TIPO_PAGO")
    private CollectType collectType;
    
    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "ID_HONORARIO", nullable = true)
    private Honorary honorary;
    
    // Motivo de del pago ya se por caso especial o lo q fuere.
    @Column(name = "MOTIVO", length = 255, nullable = true)
    private String reason;
    
    @Column(name = "FACTURA", length = 40)
    private String code;

	
	public Pay(User user, Date date, Double value, CollectType collectType,
			Honorary honorary, String reason, String code) {
		this.user = user;
		this.date = date;
		this.value = value;
		this.collectType = collectType;
		this.honorary = honorary;
		this.reason = reason;
		this.code = code;
	}

	public Pay() {
	}

	/** 
	 * @see ar.uba.fi.posgrado.common.model.AbstractDomainObject#getExcludedFields()
	 */
	@Override
	public String[] getExcludedFields() {
		return new String[]{"user", "date", "value", "collectType", "honorary", "reason", "code"};
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * @param date the date to set
	 */
	public void setDate(Date date) {
		this.date = date;
	}

	/**
	 * @return the value
	 */
	public Double getValue() {
		return value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(Double value) {
		this.value = value;
	}

	/**
	 * @return the collectType
	 */
	public CollectType getCollectType() {
		return collectType;
	}

	/**
	 * @param collectType the collectType to set
	 */
	public void setCollectType(CollectType collectType) {
		this.collectType = collectType;
	}

	/**
	 * @return the honorary
	 */
	public Honorary getHonorary() {
		return honorary;
	}

	/**
	 * @param honorary the honorary to set
	 */
	public void setHonorary(Honorary honorary) {
		this.honorary = honorary;
	}

	/**
	 * @return the reason
	 */
	public String getReason() {
		return reason;
	}

	/**
	 * @param reason the reason to set
	 */
	public void setReason(String reason) {
		this.reason = reason;
	}

	/**
	 * @return the code
	 */
	public String getCode() {
		return code;
	}

	/**
	 * @param code the code to set
	 */
	public void setCode(String code) {
		this.code = code;
	}

}
